<template>
    <div class="recommend">
        <div class="recommend-item" v-for="item in recommends.slice(0,4)" :key="item.id">
            <a href="" @click.prevent="goD(item.id)">
                <!-- <img src="~assets/images/01.jpg" alt=""> -->
                <img v-lazy="item.cover_url" alt="">
                <div>{{item.title}}</div>
            </a>
        </div>
    </div>
</template>
<script>
import {useRouter} from 'vue-router'
export default {
    name:'RecommendView',
    // 接收Home传的数据
    props: {
        // 在Home定义的recommends
        recommends: {
            type:Array,
            default(){
                return [];
            }
        }
    },
    setup(){
        const router = useRouter();
        const goD = (id)=>{
            router.push({path:'/detail',query:{id}})
        }
        return{
            goD,
            router
        }
    }
}
</script>
<style scoped lang="scss">
    .recommend{
        width: 100%;
        display: flex;
        text-align: center;
        padding: 15px 0 30px;
        border-bottom: 8px solid #EEE;
        font-size: 10px;
    }
    .recommend-item{
        flex: 1;
        img{
            width: 70px;
            height: 80px;
            margin-bottom: 10px;
        }
    }
</style>
